package com.smarthealthcare.service.impl;

import java.util.List;

import com.smarthealthcare.mapper.DepartmentMapper;
import com.smarthealthcare.mapper.RegisterMapper;
import com.smarthealthcare.project.mapper.ProjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smarthealthcare.mapper.ResultMapper;
import com.smarthealthcare.domain.Result;
import com.smarthealthcare.service.IResultService;

/**
 * 结果列表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@Service
public class ResultServiceImpl implements IResultService 
{
    @Autowired
    private ResultMapper resultMapper;
    @Autowired
    private DepartmentMapper departmentMapper;
    @Autowired
    private DoctorServiceImpl doctorService;
    @Autowired
    private ProjectMapper projectMapper;
    @Autowired
    private RegisterMapper registerMapper;

    /**
     * 查询结果列表
     * 
     * @param id 结果列表主键
     * @return 结果列表
     */
    @Override
    public Result selectResultById(Long id)
    {
        Result result = resultMapper.selectResultById(id);
        result.setDepartment(departmentMapper.selectDepartmentById(result.getDepartmentId()));
        result.setDocker(doctorService.selectDoctorById(result.getDockerId()));
        result.setProject(projectMapper.selectProjectById(result.getCheckId()));
        result.setRegister(registerMapper.selectRegisterById(result.getRegisterId()));
        return result;
    }

    /**
     * 查询结果列表列表
     * 
     * @param result 结果列表
     * @return 结果列表
     */
    @Override
    public List<Result> selectResultList(Result result)
    {
        List<Result> list = resultMapper.selectResultList(result);
        for (Result result1 : list) {
            result1.setDepartment(departmentMapper.selectDepartmentById(result1.getDepartmentId()));
            result1.setDocker(doctorService.selectDoctorById(result1.getDockerId()));
            result1.setProject(projectMapper.selectProjectById(result1.getCheckId()));
            result1.setRegister(registerMapper.selectRegisterById(result1.getRegisterId()));
        }
        return list;
    }

    /**
     * 新增结果列表
     * 
     * @param result 结果列表
     * @return 结果
     */
    @Override
    public int insertResult(Result result)
    {
        return resultMapper.insertResult(result);
    }

    /**
     * 修改结果列表
     * 
     * @param result 结果列表
     * @return 结果
     */
    @Override
    public int updateResult(Result result)
    {
        return resultMapper.updateResult(result);
    }

    /**
     * 批量删除结果列表
     * 
     * @param ids 需要删除的结果列表主键
     * @return 结果
     */
    @Override
    public int deleteResultByIds(Long[] ids)
    {
        return resultMapper.deleteResultByIds(ids);
    }

    /**
     * 删除结果列表信息
     * 
     * @param id 结果列表主键
     * @return 结果
     */
    @Override
    public int deleteResultById(Long id)
    {
        return resultMapper.deleteResultById(id);
    }

    @Override
    public List<Result> findResultByRegisterIdAndStatus(Result result) {
        List<Result> list = resultMapper.selectResultByRegisterIdAndStatus(result);
        for (Result result1 : list) {
            result1.setDepartment(departmentMapper.selectDepartmentById(result1.getDepartmentId()));
            result1.setDocker(doctorService.selectDoctorById(result1.getDockerId()));
            result1.setProject(projectMapper.selectProjectById(result1.getCheckId()));
            result1.setRegister(registerMapper.selectRegisterById(result1.getRegisterId()));
        }
        return list;
    }
}
